<?php
/*******************************************************************************
 *
 *  Controller Name: 
 *
 *  Date: 
 *  
 *  Description: 
 *  
 *  Author: 
 *  
 *  Todo:
 *     NONE
 *
 *  Modification History:  
 * 
 *   Date         Name
 *  ----------   --------------
 *  2012-04-26   DAVID JARMAN
 *  2012-04-26   DAVID JARMAN
 *  2012-04-26   DAVID JARMAN
 *  2012-04-25   HAYDEN WAISANEN
 * 
 *****************************************************************************/
?>
<?
class Manager extends CI_Controller {

   public function __contruct()
   {
      parent::__consruct(); //Manually call parent contructor
      //Check for logged in user
      $this->load->library('session');
      $this->load->helper('url');
      if(!array_key_exists('UserID',$current_user))
         redirect('/user/login');
   }
   public function index()
   {
      var_dump($this->input->post('Analyst'));
      var_dump($this->input->post('IRTeam'));
      var_dump($this->input->post('CustomerRep'));
   }

   public function assign($UserID)
   {
      $this->load->model('Analyst_model','analyst');
      $this->load->model('IRTeam_model','irteam');
      $this->load->model('CustomerRep_model','cr');
      echo $this->input->post('Analyst');
      if($this->input->post('Analyst')=='1')
      {
         //Add entry into analyst
         $this->analyst->insert(array("UserID" => $UserID));
      }
      else
      {
         //delete entry
         $this->analyst->delete($UserID);
      }
      if($this->input->post('IRTeam')==1)
      {
         //Add entry into analyst
         $this->irteam->insert(array("UserID" => $UserID));
      }
      else
      {
         //delete entry
         $this->irteam->delete($UserID);
      }
      if($this->input->post('CustomerRep')=='1')
      {
         //Add entry into analyst
         $this->cr->insert(array("UserID" => $UserID));
      }
      else
      {
         //delete entry
         $this->cr->delete($UserID);
      }
   }

   public function assignEmployees()
   {
      //Load header with menu
      $this->load->helper('dashboard_helper');
      $data['menu'] = getMenu();
      $this->load->view('headerview',$data);

      $this->load->model('User_model','user');
      $allUsers = $this->user->getAllUsers();
      $data['users'] = $allUsers;
      $this->load->view('assignemployeesview',$data);

      //Load Footer
      $this->load->view('footerview');
   }

    /************************************************************************
       Function:    viewResolvedIncidents()
       Author:      David Jarman
       Description: Loads the page that show resolved incidents
       Parameters:  (none)
     ************************************************************************/
    public function viewResolvedIncidents()
    {
        $this->load->helper('dashboard_helper');
        $data['menu'] = getMenu();
        $this->load->view('headerview',$data);

        $this->load->model('Incident_resolved_model', 'incident');
        
        $data['entries'] = $this->incident->getAll();
        $this->load->view('viewResolvedIncidents', $data);
    }

    public function viewResolvedReports($incidentID)
    {
        $this->load->helper('dashboard_helper');
        $data['menu'] = getMenu();
        $this->load->view('headerview',$data);

        $this->load->model('Report_resolved_model', 'report');

        $data['reports'] = $this->report->getWithIncidentID($incidentID);
        $this->load->view('viewResolvedReports', $data);
    }

    public function viewResolvedReport($ReportID)
    {
        //Load header with menu
        $this->load->helper('dashboard_helper');
        $data['menu'] = getMenu();
        $this->load->view('headerview',$data);

        $this->load->model('Report_resolved_model', 'report');
        $report = $this->report->getWithCustomerInfo("WHERE Report_resolved.ReportID = $ReportID");
        $report = $report[0];
        $data['Report'] = $report;
        //var_dump($report);
        $this->load->view('managerviewreport',$data);

        //Load the footer
        $this->load->view('footerview',$data);

    }
}
?>
